<template>  
	<view class="content"> 
		<view class="loginView" >
			<view class="title">
				<text>佳岚小程序</text>
			</view>
			<view>
				<u-field
					v-model="userName"
					label="用户名"
					placeholder="请填写用户名"
				>
				</u-field>
				<u-field
					v-model="password"
					label="密码"
					placeholder="请填写密码"
					password
				>
				</u-field> 
				<button class="btn"  @click="login1()">登录</button>
			</view>
		</view>
		
		<view>
			<u-toast ref="uToast" />
		</view>
	</view>
</template>

<script>
export default {
	data() {
		return {
			viewClass:null,
			userName:'',
			password:"",  
			// uToast:""
		};
	},
	methods:{
		
		login1(){ 
			uni.reLaunch({
				url:"../index/index"
			})
			
			// this.$u.post('/user/login').then(res => {
			// 	console.log(res);
			// })
			
		},
		login(){ 
			uni.reLaunch({
				url:"../index/index"
			})
			return;
			
			
			if(this.userName =="" || this.password==""){ 
				this.$refs.uToast.show({
					title: '请输入用户名和密码',
					type: 'error', 
				})
			}else{
				this.$u.put("url",{
					userName:this.userName,
					password:this.password
				}).then(res => {
					console.log(res,'返回的结果');
					if(res.code ==1){
						this.$refs.uToast.show({
							title: '登录成功',
							type: 'success', 
						})
						uni.navigateTo({
							url:"../index/index"
						})
					}else{
						this.$refs.uToast.show({
							title: '用户名或密码输入错误',
							type: 'error', 
						})
					}
				}) 
				console.log(this.userName,this.password,'核对信息')
			}
		}
	},
	 
};
</script>
<style lang="scss">
	page{
		height: 100%;
	}
	.content{
		width: 100%;
		height: 100%;
		background-size: 100%;
		background-image:linear-gradient(rgb(0,100,100),rgb(0,0,100));
		display: flex;
		align-items: center;
		justify-content: center;
		padding-bottom: 1cm;
	}
	.title{
		font-size: 27px;
		color: white;
		position: absolute;
		top: 22%;
		left: 33%;
	}
	.u-field{
		color: white;
	}
	.btn{
		background-color: green;
		margin-top: 50px;
		color: white;
	}
</style>